package routes

import (
	"PetApi/config"
	"PetApi/middlewares"
	"github.com/gin-gonic/gin"
	"os"
)

var engine *gin.Engine

func Regedit() *gin.Engine {
	// 设置运行模式
	setModel()
	if engine == nil {
		engine = gin.Default()
		engine.Use(middlewares.Page())
		if len(os.Args) == 1 {

		}
	}
	return engine
}

// setModel 设置运行模式
func setModel() {
	// 设置运行模式
	switch config.GetConfig().RunModel {
	case "release":
		gin.SetMode(gin.ReleaseMode)
	case "test":
		gin.SetMode(gin.TestMode)
	default:
		gin.SetMode(gin.DebugMode)
	}
}
